package com.hangxiang.approval.controller;

import com.hangxiang.approval.common.IntegerCommon;
import com.hangxiang.approval.common.ResultBean;
import com.hangxiang.approval.common.TempTypeInsertCommon;
import com.hangxiang.approval.common.TempTypeUpdateCommon;
import com.hangxiang.approval.service.TempTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (TempType)表控制层
 *
 * @author makejava
 * @since 2020-12-01 14:11:50
 */
@RestController
@RequestMapping("tempType")
@Api(tags = "模板类型相关功能")
public class TempTypeController {
    /**
     * 服务对象
     */
    @Resource
    private TempTypeService tempTypeService;

    /**
     * 通过主键查询单条数据
     *
     * @param common 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    @ApiOperation(value = "通过主键查询单条数据")
    @ResponseBody
    public ResultBean selectOne(@RequestBody @Validated IntegerCommon common) {
        return ResultBean.success(tempTypeService.queryById(common));
    }

    /**
     * 新增数据
     *
     * @param tempTypeInsertCommon 实例对象
     * @return 实例对象
     */
    @PostMapping("insertTempType")
    @ApiOperation(value = "添加数据")
    @ResponseBody
    public ResultBean insertTempType(@RequestBody @Validated TempTypeInsertCommon tempTypeInsertCommon) {
        return ResultBean.success(tempTypeService.insertTempType(tempTypeInsertCommon));
    }

    /**
     * 新增数据
     *
     * @param
     * @return 实例对象
     */
    @PostMapping("selectAllType")
    @ApiOperation(value = "查询所有类型")
    @ResponseBody
    public ResultBean selectAllType() {
        return ResultBean.success(tempTypeService.selectAllType());
    }


    /**
     * 新增数据
     *
     * @param tempTypeUpdateCommon 实例对象
     * @return 实例对象
     */
    @PostMapping("updateTempType")
    @ApiOperation(value = "修改isDeleted就是删除")
    @ResponseBody
    public ResultBean updateTempType(@RequestBody @Validated TempTypeUpdateCommon tempTypeUpdateCommon) {
        return ResultBean.success(tempTypeService.updateTempType(tempTypeUpdateCommon));
    }


}